<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>班级空间</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/jquery-weui.min.css">
<link rel="stylesheet" href="css/weui.min.css">
<link rel="stylesheet" href="css/index.css">
<script src="js/jquery-1.11.3.min.js"></script>
<script src="js/jquery-weui.min.js"></script>
<script src='js/swiper.min.js'></script>
<script src="js/index.js"></script>   
</head>
<body>
<div id="outwrap" style="width: 100%;height: 100%;position: relative;overflow: hidden;">
    <div class="liuyancss">                                                                                                                                   
        <div class="page-top">
            <a class="left" href="classroom_liuyanban.html" >
                <img src="images/g_03.png" width="20px" height="20px">
            </a>                   
            <a class="right" href="javascript:;" id="submit">发表</a>
        </div>
        <div class="page-wrap">
            <form id="form">
                <div class="con-text">
                    <pre id="textarea-pcon"></pre>
                    <textarea id="textarea-p" placeholder="说点什么......"></textarea>
                    <ul class="conimgs" id="conimgs">
                        <li class="zhengfang close-re"><div><img class="img" src="images/log.jpg" dpoint="center"><a class="close"></a></div></li>
                        <li class="zhengfang close-re"><div><img class="img" src="images/log.jpg" dpoint="center"><a class="close"></a></div></li>
                        <li class="zhengfang close-re"><div><img class="img" src="images/log.jpg" dpoint="center"><a class="close"></a></div></li>
                        <li class="zhengfang close-re"><div><img class="img" src="images/log.jpg" dpoint="center"><a class="close"></a></div></li>
                        <li class="zhengfang">
                            <div>
                                <a id="upBtn"><img src="images/tadd_03.png" width="100%" height="100%"></a>
                                <input type="file" id="file" name="pic" style="display: none;">
                            </div>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
    </div>       
</div>
</body>
<script>
//编辑器
$("#textarea-p").on("input",function (e) {             
    this.style.height=this.scrollHeight+'px';  
    $("#textarea-pcon").html(this.value.replace(/\n/g,"<br>"));  
})
// 添加图片
$("#upBtn").click(function(){       
    $("#file")[0].click();
})
$("#file").on("change",function(){
    var url = $.swFn.getImgurl(this);
    var img = $('<li class="zhengfang close-re"><div><img class="img" src="'+url+'" dpoint="center"><a class="close"></a></div></li>');
    $("#conimgs").prepend(img);
    $.swFn.imgCenter($.swFn.fang("#conimgs li").find(".img"));   
})

// 提交按钮
$("#submit").click(function(){
    $.showLoading();
    $.ajax({
        type:"post",
        url:"",
        data:$("#form").serialize(),
        success:function(data){
            $.hideLoading();
            $.alert("提交成功!","提示"); 


            var da = JSON.parse(data);
            console.log(da);

            
        },
        error:function(er){
            console.log(er);
        },
        timeout:5000                       //超时2秒自动退出，执行ajaxStop
    })
})

</script>
</html>